package demo.demo07.test02;

//模拟延时
public class testSleep implements Runnable {
    private int ticketNums = 10;

    @Override
    public void run() {
        while (true) {
            if (ticketNums <= 0) {
                break;
            }
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "---拿到了第" + ticketNums + "票");
        }
    }

    public static void main(String[] args) {
        testSleep testSleep = new testSleep();
        new Thread(testSleep, "老师").start();
        new Thread(testSleep, "学生").start();
        new Thread(testSleep, "家长").start();

    }
}
